home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-04-16 | 2.9 KB | 106 lines | [TEXT/CWIE] |
- // InvertedIndex.h
- // Copyright: © 1994 - 1998 by Apple Computer, Inc., all rights reserved.
-
- //// IAIndex that stores vectors.
-
- #pragma once
- #ifndef InvertedIndex_h
- #define InvertedIndex_h
-
- #pragma import on
-
- #if PRAGMA_STRUCT_ALIGN
- #pragma options align=power
- #endif
-
- #include "TermIndex.h"
- #include "FreqPosting.h"
-
- #pragma IA_BEGIN_EXPORTS
-
- const uint32 InvertedIndexType = 'Inv6';
-
- // classes needed for private member declarations
- class BitArray;
- class UInt32Set;
- class InvertedTermInfo;
- class InvertedBlockTermInfo;
-
- // FreqPosting Stream
- class FreqPS : public IAObject {
- public:
- IA_INLINE ~FreqPS() IA_INLINE_DEF() // no-op dtor def
- // Copys the next FreqPosting from the stream into the provided FreqPosting.
- // Returns NULL at the end of the stream.
- virtual bool Next(FreqPosting* posting) = 0;
- };
-
- class InvertedIndex : public virtual TermIndex {
- public:
- InvertedIndex(IAStorage* s, IACorpus* c, IAAnalysis* a,
- uint32 t = InvertedIndexType, IABlockID r = NULL);
- ~InvertedIndex();
-
- // InvertedIndex-specific methods:
- FreqPS* GetFreqPostings(TermInfo* termInfo);
- uint32 GetDeletedDocCount();
-
- // IAIndex methods we augment:
- void Initialize();
- void Open();
- void Compact();
-
- IADefineNarrowMethods(InvertedIndex, IAIndex); // support for IANarrow
-
- virtual bool ValidateTermInfos(bool verbose);
-
- virtual TermInfo* GetTermInfo(IATerm* term);
-
- protected:
- // TermIndex methods we augment to store postings:
- TermInfo* MakeTermInfo(IATerm* term, TermID id);
- TermInfo* UpdateTermInfo(TermInfo* i, FreqPosting* adds, TermFreq addCount,
- TermFreq delCount);
- TermInfo* MergeTermInfo(TermInfo* i, TermInfo* addTi, TermIndex* addIndex, DocID base);
- uint32 MergeTermCost();
- // TermIndex methods we augment to track deletions:
- IABlockSize RootSize();
- void StoreRoot(IAOutputBlock* output);
- void RestoreRoot(IAInputBlock* input);
- void Initializing();
- void DeletingDoc(DocInfo* i);
- void FinishingUpdate();
- void MergeDocIDs(TermIndex* addIndex, DocID base);
-
- // methods required for multiple inheritance
- void DeletingDocInternal(DocInfo* i);
- void DeletingPostings(IATerm* term, TermFreq delCount);
- // delete doc clean up
- void ResetPostings(TermInfo* terminfo);
- void ResetDeletedDoc(DocInfo* docInfo);
-
-
- private:
- void UpdateTermMaxDocFreq(InvertedTermInfo* iti,
- FreqPosting* adds, TermFreq addCount);
- void UpdatePostingBlocks(InvertedBlockTermInfo* iti,
- FreqPosting* adds, TermFreq addCount);
- void ExpungeTermIds(UInt32Set* deletedTermIds);
- InvertedTermInfo* ExpungePostings(InvertedTermInfo* iti);
- InvertedTermInfo* ExpungePostingsBlocks(InvertedBlockTermInfo* ibti);
-
- IABlockID deletedDocsRoot;
- BitArray* deletedDocs;
-
- InvertedIndex(InvertedIndex&); // don't define a copy constructor
- };
-
- #pragma IA_END_EXPORTS
-
- #if PRAGMA_STRUCT_ALIGN
- #pragma options align=reset
- #endif
-
- #pragma import reset
- #endif
-